package com.hookgetaway.utils;


import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
import java.util.concurrent.CountDownLatch;

/* compiled from: HandlerUtil.java */
/* loaded from: classes.dex */
public class gd0 {
    public static final Handler a = new Handler(Looper.getMainLooper());
    public static void b() {
    }

    public static /* synthetic */ void c(Runnable runnable, CountDownLatch countDownLatch) {
        runnable.run();
        countDownLatch.countDown();
    }

    public static void d(Runnable runnable) {
        a.post(runnable);
    }

    public static void postDelayed(Runnable runnable, long j) {
        a.postDelayed(runnable, j);
    }

    public static void f(@NonNull Runnable runnable) {
        a.removeCallbacks(runnable);
    }

    public static void g(Runnable runnable) {
        if (Looper.getMainLooper() == Looper.myLooper()) {
            runnable.run();
        } else {
            a.post(runnable);
        }
    }

    public static void h(final Runnable runnable) {
        final CountDownLatch countDownLatch = new CountDownLatch(1);
        g(new Runnable() { // from class: g.fd0
            @Override // java.lang.Runnable
            public final void run() {
                gd0.c(runnable, countDownLatch);
            }
        });
        try {
            countDownLatch.await();
        } catch (InterruptedException unused) {
        }
    }
}